/*
 * @Description: 
 * @Author: Gaq
 * @Date: 2022-10-13 23:24:55
 * @LastEditTime: 2022-11-27 21:28:54
 * @LastEditors: Gaq
 */
import { createWebHistory, createRouter } from "vue-router";

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path:'/',
      redirect:'/home'
    },
    {
      path: "/home",
      name: "Home",
      meta:{title:'天工开物'},
      component: ()=> import('@/views/Home/Home.vue'),
    },
    {
      path: "/heritage",
      name: "Heritage",
      meta:{title:'文化遗产'},
      component: ()=> import('@/views/CulturalHeritage/Heritage.vue'),
    },
    {
      path: "/heritageHome",
      name: "CulturalHeritage",
      meta:{title:'文化遗产'},
      component: ()=> import('@/views/CulturalHeritage/CulturalHeritage.vue'),
    },
    {
      path: "/heritageDetail/:itemId",
      name: "HeritageDetail",
      component: ()=> import('@/views/CulturalHeritage/HeritageDetail.vue'),
    },
    {
      path: "/products",
      name: "CulturalProducts",
      meta:{title:'文创产品'},
      component: ()=> import('@/views/CulturalProducts/CulturalProducts.vue'),
    },
    {
      path: "/community",
      name: "Community",
      meta:{title:'社区'},
      component: ()=> import('@/views/Community/Community.vue'),
    },
    {
      path: "/login",
      name: "Login",
      meta:{title:'登录'},
      component: ()=> import('@/views/LoginAndRegistration/Login.vue'),
    },
    {
      path:"/goodsDetail",
      name:"goodsdetail",
      component:()=> import('@/views/CulturalProducts/GoodsDetail.vue'),
    },
    {
      path:"/order",
      name:"Order",
      component:()=> import('@/views/CulturalProducts/OrderDetail.vue'),
    },
    {
      path:"/myOrderDetail",
      name:"MyOrderDetail",
      component:()=> import('@/views/CulturalProducts/MyOrderDetail.vue'),
    },
    {
      path:"/manuCenter",
      name:"manuCenter",
      meta:{title:'个人中心'},
      component:()=> import('@/views/UserCenter/ManuCenter.vue'),
    },
    {
      path:"/culCenter",
      name:"culCenter",
      meta:{title:'个人中心'},
      component:()=> import('@/views/UserCenter/CulCenter.vue'),
    },
    {
      path:"/commonCenter",
      name:"commonCenter",
      meta:{title:'个人中心'},
      component:()=> import('@/views/UserCenter/CommonCenter.vue'),
      children:[
        {
          path:"userInfo",
          name:"UserInfo",
          component:()=> import('@/components/UserInfo.vue'),
        },
        {
          path:"collection",
          name:"MyCollection",
          component:()=> import('@/views/CulturalProducts/MyCollection.vue'),
        },
        {
          path:"address",
          name:"Address",
          component:()=> import('@/views/CulturalProducts/Address.vue'),
        },
        {
          path:"shopping",
          name:"ShoppingCart",
          component:()=> import('@/views/CulturalProducts/ShoppingCart.vue'),
        },
       
        {
          path:"myOrder/:flag",
          name:"myOrder",
          component:()=> import('@/views/CulturalProducts/MyOrder.vue'),
        },
        {
          path:"myOrderPay/:flag",
          name:"myOrderPay",
          component:()=> import('@/views/CulturalProducts/MyOrder.vue'),
        },
        {
          path:"myOrderWait/:flag",
          name:"myOrderWait",
          component:()=> import('@/views/CulturalProducts/MyOrder.vue'),
        },
        {
          path:"myOrderEvaluate/:flag",
          name:"myOrderEvaluate",
          component:()=> import('@/views/CulturalProducts/MyOrder.vue'),
        },
      ]
    },
    {
      path:"/postEditor",
      name:"postEditor",
      component:()=> import('@/views/UserCenter/PostEditor.vue'),
    },
    {
      path:"/goodsEditor",
      name:"goodsEditor",
      component:()=> import('@/views/UserCenter/GoodsEditor.vue'),
    },
    {
      path:"/postDetail",
      name:"postDetail",
      component:()=> import('@/views/UserCenter/PostDetail.vue'),
    },
    {
      path:"/registration",
      name:"registration",
      meta:{title:'注册'},
      component:()=> import('@/views/LoginAndRegistration/Registration.vue'),
    },
    {
      path:"/admin",
      name:"adminLogin",
      component:()=> import('@/views/LoginAndRegistration/AdminLogin.vue'),
    },
    {
      path:"/adminCenter",
      name:"adminCenter",
      meta:{title:'个人中心'},
      component:()=> import('@/views/UserCenter/AdminCenter.vue'),
    }
  ]
})

router.beforeEach((to, from, next) => {//beforeEach是router的钩子函数，在进入路由前执行
    document.title = to.meta.title ||"天工开物"
  next()//执行进入路由，如果不写就不会进入目标页
})

export default router

